import axios from "axios";

let port = "http://localhost:4000"

export const getAll =async(keyword)=>{
    let res
     if (keyword) {
        res= await axios.get(`${port}/books/?keyword=${keyword}`)
     }else{
        res =await axios.get(`${port}/books`)
     }

    return res.data
}

export const delbooks =async (id)=>{
    let res = await axios.delete(`${port}/books/${id}`)
    return res.data
}

export const addbooks =async (obj)=>{
    let res = await axios.post(`${port}/books`,obj)
    return res.data
}

export const edit = async (id,obj)=>{
    let res = await axios.put(`${port}/books/${id}`,obj)
    return res.data
}
export const getBybooks = async(id)=>{
    let res =await axios.get(`${port}/books/${id}`)
    return res.data
}